package com.woniuxy.cloud.userassembly.utils;


import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;

import java.io.IOException;

public class Base64Utils {
    /**
     * 图片转化成base64字符串
     *
     * @param file
     * @return
     */
    public static String GetImageStr(MultipartFile file) throws IOException {
            BASE64Encoder base64Encoder =new BASE64Encoder();
            String base64EncoderImg = base64Encoder.encode(file.getBytes());// 将图片文件转化为字节数组字符串，并对其进行Base64编码处理
            return base64EncoderImg;
        }

}